import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'highlight',
  standalone: true
})
export class HighlightPipe implements PipeTransform {

  transform(value: string, search: string, classColor: string, ...args: unknown[]): unknown {
    if (!search) {
      return value;
    }
    const regex = new RegExp(`(${search})`, 'gi');
    return value.replace(regex, `<span class="${classColor}">$1</span>`);
  }

}
